﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace DbWord
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Started building of word ...");
                Stopwatch sw = Stopwatch.StartNew();

                DateTime thisDate = DateTime.Now.AddDays(-7);
                if (args.Length > 0 && 
                    !DateTime.TryParse(args[0], out thisDate))
                {
                    Console.WriteLine("Input datetime invalid, please input again.");
                    return;
                }
                // 初始化参数及载入sql
                ParametersCache.Instance.InitArgs(thisDate);

                Word word = new Word();
                word.Build();

                sw.Stop();
                Console.WriteLine("finish. cost {0:#0.00} second", sw.Elapsed.TotalSeconds);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Concat(ex.Message, "\r\n", ex.StackTrace));
            }
        }
    }
}
